import * as Type from './type'
import {fromJS} from 'immutable'

const defaultState = fromJS({
  focused: false,
  mouseIn: false,
  list: [],
  page: 1,
  totalPage: 1
});

export default (state=defaultState, action) => {
  console.log('headeraction')
  if(action.type === Type.SEARCH_FOCUS){
    return state.set('focused', true);
  }else if(action.type === Type.SEARCH_BLUR){
    return state.set('focused', false);
  }else if(action.type === Type.CHANGE_LIST){
    return state.merge({
      list: action.data,
      totalPage: action.totalPage
    })
  }else if(action.type ===Type.MOUSE_ENTER){
    return state.set('mouseIn', true)
  }else if(action.type ===Type.MOUSE_LEVEA){
    return state.set('mouseIn', false)
  }else if(action.type === Type.CHANGE_PAGE){
    return state.set('page', action.page)
  }
  return state;
}